//
//  XPauthorizationView.m
//  XPPartTime
//
//  Created by 陈李飞 on 16/7/12.
//  Copyright © 2016年 陈李飞. All rights reserved.
//

#import "XPauthorizationView.h"
#import "MYY_LoginMarco.h"
#import <Masonry.h>
@implementation XPauthorizationView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
       
        [self addSubview:self.titleLabel];
        [self addSubview:self.weixinImageView];
        [self addSubview:self.xinlangImageView];
        [self addSubview:self.QQmageView];
        [self addSubview:self.hengLine];
        [self addSubview:self.hengLine1];
    }
    return self;
}

- (void)layoutSubviews
{

    [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).with.offset(10);
        make.centerX.equalTo(self);
        make.height.mas_equalTo(kXPlogin_title_H);
       // make.width.mas_equalTo(WIDTH-100-kXPlogin_authorzayon_H*2);
        
    }];
    
    [_hengLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).with.offset(10+19.5);
        make.right.equalTo(_titleLabel.mas_left).with.offset(-20);
        make.width.mas_equalTo(kXPlogin_line_W);
        make.height.equalTo(@0.5);
        
        
    }];
    
    
    [_hengLine1 mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self).with.offset(10+19.5);
        make.left.equalTo(_titleLabel.mas_right).with.offset(20);
        make.width.mas_equalTo(_hengLine);
        make.height.mas_equalTo(0.5);
        
    }];
   
    [_weixinImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_titleLabel.mas_bottom).with.offset(20);
        make.left.equalTo(self).with.offset(70);
        make.height.and.width.mas_equalTo(kXPlogin_authorzayon_H);
        
    }];
    [_xinlangImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_weixinImageView);
        make.centerX.equalTo(self);
        make.height.and.width.mas_equalTo(kXPlogin_authorzayon_H);
        
    }];
    [_QQmageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_weixinImageView);
        make.right.equalTo(self).with.offset(-70);
        make.height.and.width.mas_equalTo(kXPlogin_authorzayon_H);
        
    }];
    
    UITapGestureRecognizer *tapScrollView = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(weixinImageViewGes)];
    [_weixinImageView addGestureRecognizer:tapScrollView];
    UITapGestureRecognizer *tapScroll = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(xinlangImageViewGes)];
    [_xinlangImageView addGestureRecognizer:tapScroll];
    UITapGestureRecognizer *tapScr = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(QQmageV)];
    [_QQmageView addGestureRecognizer:tapScr];
    //FIXME: - 第三方登录暂时隐藏
    _weixinImageView.hidden = YES;
    _xinlangImageView.hidden = YES;
    _QQmageView.hidden  = YES;
    
}
-(void)weixinImageViewGes{
    if (self.weixinImageViewB) {
        self.weixinImageViewB();
    }
}

-(void)xinlangImageViewGes{
    if (self.QQmageView) {
        self.QQmageViewB();
    }
}

-(void)QQmageV{
    if (self.xinlangImageViewB) {
        self.xinlangImageViewB();
    }
    
}
#pragma mark - property
- (UILabel *)titleLabel
{
    if (_titleLabel == nil) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = MYYFont(14.0f);
        _titleLabel.numberOfLines = 1;
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        _titleLabel.textColor = [UIColor whiteColor];
        _titleLabel.text = @"社交账号快速登录";
    }
    return _titleLabel;
}
- (UIImageView *)weixinImageView
{
    if (_weixinImageView == nil) {
        _weixinImageView = [[UIImageView alloc] init];
        _weixinImageView.image =[UIImage imageNamed:@"weixin"];
        _weixinImageView.userInteractionEnabled = YES;
    }
    return _weixinImageView;
}

- (UIImageView *)xinlangImageView
{
    if (_xinlangImageView == nil) {
        _xinlangImageView = [[UIImageView alloc] init];
        _xinlangImageView.image =[UIImage imageNamed:@"weibo"];
        _xinlangImageView.userInteractionEnabled = YES;
    }
    return _xinlangImageView;
}
- (UIImageView *)QQmageView
{
    if (_QQmageView == nil) {
        _QQmageView = [[UIImageView alloc] init];
        _QQmageView.image =[UIImage imageNamed:@"qq"];
        _QQmageView.userInteractionEnabled = YES;
    }
    return _QQmageView;
}

- (UIView *)hengLine
{
    if (_hengLine == nil) {
        _hengLine = [[UIView alloc] init];
        _hengLine.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"zuoxian"]];
    }
    return _hengLine;
}

- (UIView *)hengLine1
{
    if (_hengLine1 == nil) {
        _hengLine1 = [[UIView alloc] init];
        _hengLine1.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"youxian"]];
    }
    return _hengLine1;
}

@end
